<div class="m-tab s-tab">
  <h2 class="u-tt">会员组管理</h2>
  <ul class="u-tabs">
    <li><a href="{$url|'AdminMemberGroup/index'}">会员组列表</a></li>
    <li><a href="#tab1" class="tab-on tab-a" >{$actionName}会员组</a></li>
    <li><a href="#tab2" class="tab-a">权限设置</a></li>
  </ul>
</div>
<div class="m-form">
  <form name="" action="<?php echo url('AdminMemberGroup/'.$action.'Data'); ?>" method="post" id="form">
    <fieldset>
      <div id="tab1">
      	<div class="formitm">
          <label class="lab">上级用户组：</label>
          <div class="ipt">
            <select class="u-slt" id="parent_id" name="parent_id">
              <option value="0">==顶级组==</option>
              <!--{loop="$groupList $vo"}-->
              <option {if="$info['parent_id']==$vo['group_id']"} selected="selected"{/if} value="{$vo.group_id}">
              {$vo.cname}
              </option>
              <!--{/loop}-->
            </select>
            <p>上级用户组只做显示使用，无权限等影响</p>
          </div>
        </div>
        <div class="formitm">
          <label class="lab">组名称：</label>
          <div class="ipt">
            <input name="name" type="text" class="u-ipt u-ipt-5" id="name" value="{$info.name}" maxlength="100" datatype="s" />
            <p></p>
          </div>
        </div>
        <div class="formitm">
          <label class="lab">组顺序：</label>
          <div class="ipt">
          	<?php if(!isset($info['sequence'])){ $info['sequence']=0; } ?>
            <input name="sequence" type="text" class="u-ipt u-ipt-5" id="sequence" value="{$info.sequence}" maxlength="100" datatype="s" />
            <p>数字越小越考前显示</p>
          </div>
        </div>
        <div class="formitm">
          <label class="lab" >登录状态：</label>
          <div class="ipt">
            <?php if(!isset($info['status'])){ $info['status']=1; } ?>
            <label class="u-opt">
              <input name="status" type="radio" value="1" {if="$info['status']==1"} checked="checked" {/if} />
              正常</label>
            <label class="u-opt">
              <input name="status" type="radio" value="0" {if="$info['status']==0"} checked="checked" {/if} />
              禁止</label>
          </div>
        </div>
      </div>
      <div id="tab2"  class="m-tabpanel">
        <div class="formitm">
          <label class="lab">选择操作权限：</label>
          <div class="ipt">
            <button class="u-btn" type="button" id="selectPurvewAll">全选</button>
            <button class="u-btn" type="button" id="selectPurvew">反选</button>
            <span class="suffix">选择模块后续功能才能使用</span> </div>
        </div>
        <?php
        if(!empty($MenberPurvew)){   foreach ((array)$MenberPurvew as $key => $app){ {if(!empty($app)){ foreach ((array)$app as $listMode => $list) { ?>
        <div class="formitm">
          <label class="lab">{$list.name}：</label>
          <div class="ipt">
            <label class="u-opt">
              <input name="MemberPurvew[]" class="MemberPurvew" {if="in_array($key.'_'.$listMode,(array)$MemberPurvewArray)"} checked {/if} type="checkbox" value="{$key}_{$listMode}">
              模块</label>
            <?php if(!empty($list['auth'])){ foreach ($list['auth'] as $action => $vo) { ?>
            <?php if(in_array($key.'_'.$listMode.'_'.$action,(array)$MemberPurvewArray)){ $checked='checked'; }else { $checked= '' ;} ?>
            <label class="u-opt">
              <input name="MemberPurvew[]" class="MemberPurvew" {$checked} type="checkbox" value="{$key}_{$listMode}_{$action}">
              {$vo}</label>
            &nbsp;&nbsp;
            <?php }} ?>
          </div>
          <div class="f-cb"></div>
        </div>
        <?php } } } } } ?>
        <div class="formitm">
          <label class="lab">选择菜单权限：</label>
          <div class="ipt">
            <button class="u-btn" type="button" id="selectMenuAll">全选</button>
            <button class="u-btn" type="button" id="selectMenu">反选</button>
            <span class="suffix">选择主菜单后下级菜单才能设置</span> </div>
        </div>
        <?php if(!empty($MemberMenu)){ foreach ($MemberMenu as $topLabel => $top) {?>
        <div class="formitm ">
          <label class="lab">{$top.name}：</label>
          <div class="ipt">
            <fieldset  class="m-fieldset">
            <legend ><label class="u-opt">
						<input name="MemberMenu[]" class="MemberMenu" type="checkbox" {if="in_array($top['name'],(array)$MemberMenuArray)"} checked {/if}  value="<?php echo $top['name']; ?>">
						{$top.name}
						</label></legend>
              <?php if(!empty($top['menu'])){ foreach ($top['menu'] as $parentLabel => $parent) { ?>
              <label class="u-opt">
                <input name="MemberMenu[]" class="MemberMenu" type="checkbox" {if="in_array($parent['url'],(array)$MemberMenuArray)"} checked {/if}  value="<?php echo $parent['url']; ?>">
                {if="is_array($parent['name'])"} {$parent.name.0} {else} {$parent.name}  {/if} </label>
              <?php } } ?>
            </fieldset>
          </div>
          <div class="f-cb"></div>
        </div>
        <?php } } ?>
      </div>
      <div class="formitm formitm-1  formitm-2">
        <input name="group_id" type="hidden" value="{$info.group_id}" />
        <button class="u-btn" type="submit">保存</button>
        <button class="u-btn s-btn-c3" type="reset">重置</button>
        <span class="status" id="status"></span> </div>
    </fieldset>
  </form>
</div>
<script>
Do.ready('base','form','dialog','tabs',function() {
	$('#selectPurvewAll').click(function(){
		$(".MemberPurvew").attr("checked",'true');
	});
	$('#selectPurvew').click(function() {
		$(".MemberPurvew").each(function(){
		if($(this).attr('checked')){   
			  $(this).removeAttr("checked");   
		}else{   
			  $(this).attr("checked",'true');   
		}   
		})
	});
	$('#selectMenuAll').click(function(){
		$(".MemberMenu").attr("checked",'true');
	});
	$('#selectMenu').click(function() {
		$(".MemberMenu").each(function(){
		if($(this).attr('checked')){   
			  $(this).removeAttr("checked");   
		}else{   
			  $(this).attr("checked",'true');   
		}   
		})
	});
	$('#form').duxForm({returnUrl:'{$url|"AdminMemberGroup/index"}'});
	$(".u-tabs li .tab-a").powerSwitch( { classAdd : "tab-on" });
});
</script>